<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>

<?php
    $_product = $this->getProduct();
?>
<?php if ($_product->isSaleable() && $this->hasOptions()): ?>
<div id="bundleSummary"
     class="block-bundle-summary"
     data-mage-init='{"sticky":{"container": ".product-add-form"}}'>
    <div class="title">
        <strong><?php echo __('Your Customization'); ?></strong>
    </div>
    <div class="content">
        <div class="bundle-info">
            <?php echo $this->getLayout()->createBlock('Magento\Catalog\Block\Product\Image')->init($_product, 'bundled_product_customization_page')->toHtml() ?>
            <div class="product-details">
                <strong class="product name"><?php echo $this->escapeHtml($_product->getName()) ?></strong>
                <?php if($_product->getIsSalable()): ?>
                    <p class="available stock" title="<?php echo __('Availability') ?>">
                        <span><?php echo __('In stock') ?></span>
                    </p>
                <?php else: ?>
                    <p class="unavailable stock" title="<?php echo __('Availability') ?>">
                        <span><?php echo __('Out of stock') ?></span>
                    </p>
                <?php endif; ?>
                <?php echo $this->getChildHtml('', true);?>
            </div>
        </div>
        <div class="bundle-summary">
            <strong class="subtitle"><?php echo __('Summary'); ?></strong>
            <div id="bundle-summary" data-container="product-summary">
                <ul data-mage-init='{"productSummary": []}' class="bundle items"></ul>
                <script data-template="bundle-summary" type="text/x-jQuery-tmpl">
                    <li>
                        <strong class="label">${_label_}:</strong>
                        <div data-container="options"></div>
                    </li>
                </script>
                <script data-template="bundle-option" type="text/x-jQuery-tmpl">
                    <div><?php echo __('%1 x %2', '${_quantity_}', '${_label_}') ?></div>
                </script>
            </div>
        </div>
    </div>
</div>
<script>
    require([
        "jquery",
        "mage/mage"
    ], function($){
        $('.product-add-form').mage('slide', {
            'slideSpeed': 1500,
            'slideSelector': '#bundle-slide',
            'slideBackSelector': '.action.customization.back',
            'bundleProductSelector': '#bundleProduct',
            'bundleOptionsContainer': '.product-add-form',
            <?php if ($this->isStartCustomization()): ?>
            'autostart': true
            <?php endif;?>
        });
    });
</script>
<?php endif; ?>
